/**
   UserLoginFilter
 * Time:2018年6月14日
 */
package com.ssm.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ssm.entity.Usermessage;

/**
 * @author 15199
 *
 */
@SuppressWarnings("all")
public class UserLoginFilter implements Filter {


	@Override
	public void init(FilterConfig filterConfig) throws ServletException {

	}
	@Override
	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException {
		HttpServletRequest httprequest=(HttpServletRequest) request;
		HttpServletResponse httpresponse=(HttpServletResponse) response;
		Usermessage usermessage=(Usermessage) httprequest.getSession().getAttribute("usermessage");
	    String id= httprequest.getParameter("id");
	    httprequest.getSession().setAttribute("id",id);
		if(usermessage!=null){
			chain.doFilter(httprequest, httpresponse);
		}else{
            httpresponse.sendRedirect("/jsp/FG/Login.jsp");
		}
	}
	@Override
	public void destroy() {
	}
}
